package top.lihope.respond;

public class R<T> {

	private Boolean success;
	private String message;
	private Integer code;
	private T data;

	public R() {
		this.success=true;
		this.message = "操作成功";
		this.code = 200;
	}
	public R(boolean success) {
		this.success = success;
		this.message = "操作失败";
		this.code = 500;
	}

	public R(Integer code,String message, T data) {
		super();
		this.success = false;
		this.message = message;
		this.code = code;
		this.data = data;
	}

	public R(boolean success, String message, Integer code, T data) {
		super();
		this.success = success;
		this.message = message;
		this.code = code;
		this.data = data;
	}


	public Boolean getOk() {
		return success;
	}
	public String getMessage() {
		return message;
	}
	public Integer getCode() {
		return code;
	}
	public T getData() {
		return data;
	}

	public R<T> setMessage(String message) {
		this.message = message;
		return this;
	}
	public R<T> setCode(Integer code) {
		this.code = code;
		return this;
	}
	public R<T> setData(T data) {
		this.data = data;
		return this;
	}



	public static <T> R<T> success(){
		return new R<T>();
	}

	public static <T> R<T> error(){
		return new R<T>(false);
	}

}
